home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / emula / arosdv19.lha / AROS / config / dummy / superstate. < prev    next >
Text File  |  1996-09-12  |  1KB  |  69 lines

  1. |*****************************************************************************
  2. |
  3. |   NAME
  4. |
  5. |    __AROS_LH0(APTR, SuperState,
  6. |
  7. |   SYNOPSIS
  8. |
  9. |   LOCATION
  10. |    struct ExecBase *, SysBase, 25, Exec)
  11. |
  12. |   FUNCTION
  13. |    Enter supervisor mode (like Supervisor()), but return on the normal
  14. |    user stack, so that user stack variables are still there. A call
  15. |    to Userstate() will end this mode.
  16. |
  17. |   INPUTS
  18. |
  19. |   RESULT
  20. |    Old supervisor stack. NULL if called from supervisor mode.
  21. |
  22. |   NOTES
  23. |    The user stack must be big enough to hold all possible nestings
  24. |    of interrupts.
  25. |
  26. |   EXAMPLE
  27. |
  28. |   BUGS
  29. |
  30. |   SEE ALSO
  31. |    UserState(), Supervisor()
  32. |
  33. |   INTERNALS
  34. |
  35. |   HISTORY
  36. |
  37. |******************************************************************************
  38.  
  39.     Supervisor  =    -0x1e
  40.  
  41.     .globl    _Exec_SuperState
  42. _Exec_SuperState:
  43.     | Goto supervisor mode. Preserve a5 in d0 (faster than stack space)
  44.     movel    a5,d0
  45.     leal    super,a5
  46.  
  47.     | Do not change user stack - use jmp
  48.     jmp    a6@(Supervisor)
  49. super:
  50.     | Restore a5
  51.     movel    d0,a5
  52.  
  53.     | Check if called from supervisor mode
  54.     btst    #5,sp@
  55.     jeq    fromuser
  56.  
  57.     | Called from supervisor mode. Just return NULL.
  58.     moveql    #0,d0
  59.     rte
  60.  
  61. fromuser:
  62.     | Called from user mode. Restore sp and return supervisor sp.
  63.     movel    sp,d0
  64.     movel    usp,sp
  65.  
  66.     | usp already points to the returnaddress for the SuperState() call.
  67.     rts
  68.  
  69.